home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / JUSTIFY1.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  1KB  |  56 lines

  1. ;***********************************;
  2. ; WASM String Right Justify         ;
  3. ; By Eric Tauck                     ;
  4. ;                                   ;
  5. ; Defines:                          ;
  6. ;                                   ;
  7. ;   StrJusR  right justify a string ;
  8. ;                                   ;
  9. ; Requires:                         ;
  10. ;                                   ;
  11. ;    STRING.ASM                     ;
  12. ;***********************************;
  13.  
  14.         jmps    _justify1_end
  15.  
  16. ;========================================
  17. ; Right justify a string.
  18. ;
  19. ; In: AX= string; CX= final length of
  20. ;     string; DL= pad character.
  21.  
  22. StrJusR PROC    NEAR
  23.         push    di
  24.         push    si
  25.  
  26.         push    cx
  27.         push    dx
  28.         mov     si, ax
  29.         call    StrLen          ;get length
  30.         pop     dx
  31.         pop     cx
  32.         sub     cx, ax          ;characters to pad
  33.         jbe     _stjur1         ;exit if no padding
  34.  
  35.         push    cx
  36.         add     si, ax          ;point to last byte
  37.         mov     di, si
  38.         add     di, cx          ;new end of string
  39.         mov     cx, ax
  40.         inc     cx              ;include NUL
  41.         std
  42.         rep
  43.         movsb                   ;shift string
  44.         pop     cx
  45.  
  46.         mov     al, dl
  47.         rep
  48.         stosb                   ;store padding
  49.  
  50. _stjur1 pop     si
  51.         pop     di
  52.         ret
  53.         ENDP
  54.  
  55. _justify1_end
  56.